package cn.felord.common.security;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;

/**
 * @author Dax
 * @since 13:28  2018/9/21
 */

public class JwtTokenCacheStorage implements JwtTokenStorage {
    private static final String TOKEN_CACHE = "usrTokenCache";


    @CachePut(value = TOKEN_CACHE, key = "#userId")
    @Override
    public JwtEntity put(JwtEntity jwtEntity, String userId) {
        return jwtEntity;
    }

    @CacheEvict(value = TOKEN_CACHE, key = "#userId")
    @Override
    public void expire(String userId) {
//        EhcacheHelper.remove(TOKEN_CACHE, userId);
    }

    @CachePut(value = TOKEN_CACHE, key = "#userId")
    @Override
    public JwtEntity refresh(JwtEntity jwtEntity, String userId) {
        return jwtEntity;
    }

    @Cacheable(value = TOKEN_CACHE, key = "#userId")
    @Override
    public JwtEntity get(String userId) {
        return null;
    }
}
